I'm trying to write a DXL script to search a string containing the Object Number attribute in the objects of a module and replace this string by the Object Identifier.
for obj in all current Module do {
Krogen - Fri Feb 10 07:17:47 EST 2012 |
Re: Loop in reverse order. Regards Stefan |
Re: Loop in reverse order. ambes_gt - Fri Feb 10 07:53:51 EST 2012 I compare a string with the Object Number and I don't really know how compare the length of the string can help me. Example: Object Number: 1.2 => Length = 3 Requirement: This functionality is explained in 2.1.2. The string can be found in 2.1.2 with the length = 3 too. |
Re: Loop in reverse order. Krogen - Fri Feb 10 08:56:10 EST 2012
I guess instead of blindly replacing the object number in your attribute, you could first extract the full object number in that attribute and then compare it to the one you are searching for. You can use a regular expression for that. Note that in DOORS object numbers can also contain '-' for text objects or childs of them.
string sSearch = "1.1.1"
string theAttribute = "myAttributeName"
Regexp reNumber = regexp "[-.0-9]+"
Object o
for o in all current Module do {
string s = o.theAttribute
if (reNumber s) {
string sFound = s[match 0]
print "Found number: " sFound "\n"
if (sSearch == sFound) {
// replace here
}
}
}
Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS
|
Re: Loop in reverse order. Mathias Mamsch - Fri Feb 10 10:06:37 EST 2012
I guess instead of blindly replacing the object number in your attribute, you could first extract the full object number in that attribute and then compare it to the one you are searching for. You can use a regular expression for that. Note that in DOORS object numbers can also contain '-' for text objects or childs of them.
string sSearch = "1.1.1"
string theAttribute = "myAttributeName"
Regexp reNumber = regexp "[-.0-9]+"
Object o
for o in all current Module do {
string s = o.theAttribute
if (reNumber s) {
string sFound = s[match 0]
print "Found number: " sFound "\n"
if (sSearch == sFound) {
// replace here
}
}
}
Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS
With the Regexp and the Match expresions, I am able to filter the words. Thank you very much. |